package com.masterclient.app.modules.shop.widget;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;

import com.eoner.baselibrary.utils.ScreenUtils;
import com.masterclient.app.R;
import com.gyf.immersionbar.ImmersionBar;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @auther hjian
 * @date 2020/6/8.
 */
public class GuideDealerBenchDialog extends Dialog {

    @BindView(R.id.dialog_guide_dealer_bench_iv)
    ImageView dialogGuideDealerBenchIv;
    @BindView(R.id.dialog_guide_dealer_bench_root)
    View dialogGuideDealerBenchRoot;

    Activity context;
    int index = 0;
    int[] images = {R.mipmap.guide_dealer_bench_one, R.mipmap.guide_dealer_bench_two};


    public GuideDealerBenchDialog(@NonNull Activity context, int index,ClickImage clickImage) {
        super(context, R.style.MyDialog);
        this.context = context;
        this.index = index;
        this.clickImage = clickImage;
    }

    @Override
    protected void onStart() {
        super.onStart();
        Window window = getWindow();
        WindowManager.LayoutParams windowParams = window.getAttributes();
        windowParams.width = WindowManager.LayoutParams.MATCH_PARENT;
        windowParams.height = WindowManager.LayoutParams.MATCH_PARENT;
        window.setBackgroundDrawableResource(android.R.color.transparent);
        window.setAttributes(windowParams);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_guide_dealer_bench);
        ButterKnife.bind(this);
        ImmersionBar.with(context,this).fitsSystemWindows(true).init();
//        dialogGuideDealerBenchRoot.setPadding(0,ImmersionBar.getStatusBarHeight(context),0,0);
        setCanceledOnTouchOutside(false);
    }

    public void setNextImages(){
        index =  1 ;
        dialogGuideDealerBenchIv.setImageResource(images[1]);
        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) dialogGuideDealerBenchIv.getLayoutParams();
        layoutParams.setMargins(0,0,0,ScreenUtils.dp2px(50));
        layoutParams.gravity = Gravity.BOTTOM|Gravity.LEFT;
    }


    @OnClick({R.id.dialog_guide_dealer_bench_iv,R.id.dialog_guide_dealer_bench_root})
    public void onViewClicked(View v) {
        switch (v.getId()){
            case R.id.dialog_guide_dealer_bench_iv:
                clickImage.onClickImg(index);
                break;
            case R.id.dialog_guide_dealer_bench_root:
//                dismiss();
                break;
        }
    }

    private ClickImage clickImage;
    public interface ClickImage{
        void onClickImg(int index);
    }
}
